package com.yuexun.dhdoctor.module.meetingNew.presenter.impl;

import com.yuexun.dhdoctor.base.BaseEntity;
import com.yuexun.dhdoctor.module.meetingNew.model.IMeetingNewModel;
import com.yuexun.dhdoctor.module.meetingNew.presenter.IMeetingNewCheckByQrCodePresenter;
import com.yuexun.dhdoctor.module.meetingNew.ui.view.IMeetingNewCheckByQrCodeView;

import org.kymjs.kjframe.ui.ViewInject;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by wangt on 2018/4/24.
 */
public class MeetingNewCheckByQrCodePresenter implements IMeetingNewCheckByQrCodePresenter {
    private IMeetingNewModel model;
    private IMeetingNewCheckByQrCodeView view;

    public MeetingNewCheckByQrCodePresenter(IMeetingNewModel model, IMeetingNewCheckByQrCodeView view) {
        this.model = model;
        this.view = view;
    }

    @Override
    public void checkMeetingByQrCode(Map<String, String> praise) {
        model.checkMeetingByQrCode(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BaseEntity<String>>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        ViewInject.toast("请检查网络状态");
                    }

                    @Override
                    public void onNext(BaseEntity<String> bean) {
                        view.checkByQrCode(bean);
                    }
                });
    }
}
